package com.meihuayishu.backend.dto;

import lombok.Data;
import lombok.Builder;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import io.swagger.v3.oas.annotations.media.Schema;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.List;
import java.util.Map;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(description = "卦象详细信息响应")
public class HexagramDetailResponse {
    
    @Schema(description = "卦象ID", example = "1")
    private Long id;
    
    @Schema(description = "卦象名称", example = "乾为天")
    private String name;
    
    @Schema(description = "卦象编码", example = "QIAN_WEI_TIAN")
    private String code;
    
    @Schema(description = "上卦")
    private TrigramDetail upperTrigram;
    
    @Schema(description = "下卦")
    private TrigramDetail lowerTrigram;
    
    @Schema(description = "卦辞", example = "天行健，君子以自强不息")
    private String hexagramText;
    
    @Schema(description = "卦象描述")
    private String description;
    
    @Schema(description = "五行关系", example = "比和")
    private String elementRelation;
    
    @Schema(description = "卦象解读")
    private Interpretation interpretation;
    
    @Schema(description = "应用指导")
    private Map<String, String> applications;
    
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @Schema(description = "三元组详细信息")
    public static class TrigramDetail {
        @Schema(description = "名称", example = "乾")
        private String name;
        
        @Schema(description = "符号", example = "☰")
        private String symbol;
        
        @Schema(description = "属性", example = "天")
        private String nature;
        
        @Schema(description = "五行", example = "金")
        private String element;
        
        @Schema(description = "特性", example = "刚健")
        private String attribute;
        
        @Schema(description = "意义")
        private String meaning;
    }
    
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @Schema(description = "卦象解读")
    public static class Interpretation {
        @Schema(description = "总体解读")
        private String general;
        
        @Schema(description = "卦辞")
        private String judgment;
        
        @Schema(description = "象辞")
        private String image;
        
        @Schema(description = "爻辞")
        private List<LineText> lines;
    }
    
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @Schema(description = "爻辞")
    public static class LineText {
        @Schema(description = "爻位", example = "1")
        private Integer position;
        
        @Schema(description = "爻辞文本", example = "初九：潜龙勿用")
        private String text;
        
        @Schema(description = "爻辞含义")
        private String meaning;
    }
}